import { Dimensions, Platform, PixelRatio } from "react-native";
import { Header } from "react-navigation";
import Color from "./color";
import RefreshState from "./RefreshState";
import storage from "./Storage";
import EnumConstants from "./EnumConstants";

const isIphoneX = Platform.OS === "ios" && Dimensions.get("window").height === 812;
const isIOS = Platform.OS === "ios";
const ScreenWidth = Dimensions.get("window").width;
const ScreenHeight = Dimensions.get("window").height;
const screenPxWidth = PixelRatio.getPixelSizeForLayoutSize(ScreenWidth);
const screenPxHeight = PixelRatio.getPixelSizeForLayoutSize(ScreenHeight);
const designWidth = 750.0;
const designHeight = 1334.0;
const scaleWidth = screenPxWidth / designWidth;
const scaleHeight = screenPxHeight / designHeight;
const scale = isIOS ? Math.min(Math.min(scaleWidth, scaleHeight), 1) : 1;
const FONT_SCALE = isIOS ? scale : 1;
const headerHeight = Header.height;
const FontSize = {
  SIZE_90: Platform.select({
    ios: 90 * FONT_SCALE,
    android: 90,
  }),
  SIZE_33: Platform.select({
    ios: 33 * FONT_SCALE,
    android: 33,
  }),
  SIZE_32: Platform.select({
    ios: 32 * FONT_SCALE,
    android: 32,
  }),
  SIZE_28: Platform.select({
    ios: 28 * FONT_SCALE,
    android: 28,
  }),
  SIZE_26: Platform.select({
    ios: 26 * FONT_SCALE,
    android: 26,
  }),
  SIZE_24: Platform.select({
    ios: 24 * FONT_SCALE,
    android: 24,
  }),
  SIZE_22: Platform.select({
    ios: 22 * FONT_SCALE,
    android: 22,
  }),
  SIZE_20: Platform.select({
    ios: 20 * FONT_SCALE,
    android: 20,
  }),
  SIZE_18: Platform.select({
    ios: 18 * FONT_SCALE,
    android: 18,
  }),
  SIZE_19: Platform.select({
    ios: 19 * FONT_SCALE,
    android: 19,
  }),
  SIZE_17: Platform.select({
    ios: 17 * FONT_SCALE,
    android: 17,
  }),
  SIZE_16: Platform.select({
    ios: 16 * FONT_SCALE,
    android: 16,
  }),
  SIZE_15: Platform.select({
    ios: 15 * FONT_SCALE,
    android: 15,
  }),
  SIZE_14: Platform.select({
    ios: 14 * FONT_SCALE,
    android: 14,
  }),
  SIZE_13: Platform.select({
    ios: 13 * FONT_SCALE,
    android: 13,
  }),
  SIZE_12: Platform.select({
    ios: 12 * FONT_SCALE,
    android: 12,
  }),
  SIZE_10: Platform.select({
    ios: 10 * FONT_SCALE,
    android: 10,
  }),
  SIZE_2: Platform.select({
    ios: 2 * FONT_SCALE,
    android: 2,
  }),
  SIZE_48: Platform.select({
    ios: 48 * FONT_SCALE,
    android: 48,
  }),
  SIZE_30: Platform.select({
    ios: 30 * FONT_SCALE,
    android: 30,
  }),
};

module.exports = {
  Color,
  isIOS,
  isIphoneX,
  RefreshState,
  storage,
  FontSize,
  EnumConstants,
  ScreenWidth,
  ScreenHeight,
  scaleWidth,
  scaleHeight,
  scale,
  headerHeight,
};
